home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSList-0198 / AMOSLIST / text0014.txt < prev    next >
Encoding:
Text File  |  1998-06-24  |  3.6 KB  |  92 lines

  1. On 02-Jan-98, Timo Engman smashed the keyboard with:
  2. >Hello.
  3.  
  4. >I'm Timo Engman, and programming a new extension - which is called 
  5. >"Second-Hand Extension", the current version is 0.01d6 but please, all 
  6. >AMOSPro users - mail me and let me hear if I may add new commands to this 
  7. >extension that the users want...For now, the extension have five commands 
  8. >:-) pretty lame. But I learning how to program the graphics...
  9.  
  10. >The extension uses slot 22 but mail me and I may change it to whatever.
  11. >Check the aminet/dev/amos/ for this extension...later...
  12. >Maybe I mail the .Lib file soon, to the Mailing List.
  13.  
  14. I've added your extension to the extensionlist at my site, if you'd like to
  15. see what slots are used and for what you can always drop by :))
  16.  
  17. ---
  18.  
  19. >A Problem 1: How to return a string from a routine (and change it's 
  20. >length) from it, the string is in the extension
  21.  
  22. >dc.w TheLength
  23. >dc.b "TheString",0
  24. >even
  25.  
  26. You need to ask for memory and then build the right structure, when looking
  27. at the string the first 2 bytes (word) holds the length of the string, then
  28. at the 3rd byte the string itselve starts. You can see this by trying to
  29. define a string in AMOS and then do a Deek(Varptr(W$)-2), that'll return
  30. the 'len'..
  31.  
  32. Here's a way to do it:
  33.  First you ask for the stringspace (needed length in both d3 & d0)
  34.  
  35.                                         ;Ask for string space...
  36.         and.w   #$FFFE,d3               * Only EVEN!
  37.         addq.w  #2,d3
  38.         Rjsr    L_Demande
  39.         lea     2(a1,d3.w),a1
  40.         move.l  a1,HiChaine(a5)
  41.         move.l  a0,STa_d(pc)            * Store adress     
  42.         move.w  d0,(a0)+                * Store length
  43.  
  44.  Now the structure-adress of the new string is placed in a locale 
  45.  data-area to be returned to the caller, and the room for the string
  46.  itselve is pointed by a0, be carefull not to swap these as they differs
  47.  by 2 bytes !!!!..
  48.  Then create the string with the first character starting in the adress
  49.  pointed by a0, and end your procedure with:
  50.  
  51.         move.l  STa_d(pc),d3            ;Stringadress
  52.         moveq.l #2,d2                   ;Returning a string
  53.         rts
  54.  
  55.  (Remeber to clean up the stack BEFORE you put this, I'd forgotten once,
  56.  and the same bug can be found in the IO_devices 2.0)
  57.  
  58.  That should return the string to the caller..
  59.  
  60. ---
  61.  
  62. >Problem 2: How to get a pointer from the extension in assembler, 
  63. >typically i want the pointer for a variable, same as Varptr(variable) and 
  64. >pointer for an array, same as Varptr(var(array))
  65.  
  66. I havn't got a clue, I've been looking for a solve for the same problem
  67. some time. I think it's hidden somewhere in the include files that
  68. comes with AMOSPro.. Unfortunaly they're not very well documented..
  69.  
  70. ---
  71.  
  72. >Hope that all peoples understanding my bad english (I'm swedish)...And 
  73. >those people who don't like the assembler language.
  74.  
  75. And I'm danish, so that isn't much better :)
  76.  
  77. -- 
  78. Happy greetings, Yours..
  79. __________________________________________________________________________
  80.  /_  __/ __  / __  /\  ___\  __ \__  _\           aka. JENS VANG PETERSEN
  81.   / / / /_/ / ____/  \ \___\  __ \ \ \  Nyvej 8, DK-4450 Jyderup, Denmark
  82.  /_/ /_____/_/        \_____\_\ \_\ \_\             top_cat@post8.tele.dk
  83. --------------------------------------------------------------------------
  84.                      http://home8.inet.tele.dk/top_cat/
  85.   -*-  Home of 'The Ultimate Extension list' for AMOS TC & AMOS PRO  -*-
  86.                 -*-  AMOS Ring - AMIGA Ring - AQUA Ring  -*-
  87. --------------------------------------------------------------------------
  88.  Foolproof operation = All parameters are hard coded.
  89. --------------------------------------------------------------------------
  90.  
  91.  
  92.